//
//  TieDeatailHeaderView.m
//  Car
//
//  Created by dllo on 15/10/31.
//  Copyright © 2015年 岳明. All rights reserved.
//

#import "TieDeatailHeaderView.h"
#define WIDTH [UIScreen mainScreen].bounds.size.width
#define HEIGHT [UIScreen mainScreen].bounds.size.height
@interface TieDeatailHeaderView ()

@property (nonatomic, strong) UIView *backView;
@property (nonatomic, strong) UILabel *moreLabel;

@property (nonatomic, copy) void(^block1)(UITouch *touch);
@property (nonatomic, copy) void(^block2)(UITouch *touch);
@end

@implementation TieDeatailHeaderView

- (instancetype)initWithFrame:(CGRect)frame Completion:(void(^)(UITouch *touch))block1 WithMore:(void(^)(UITouch *touch)) block2 {
    self = [super initWithFrame:frame];
    if (self) {
        self.block1 = block1;
        self.block2 = block2;
        
        self.backView = [[UIView alloc] initWithFrame:CGRectMake(10*WIDTH/375, 10*HEIGHT/667, WIDTH/6, 40*HEIGHT/667)];
        [self addSubview:self.backView];
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 14*HEIGHT/667, WIDTH/18, 22*HEIGHT/667)];
        imageView.image = [UIImage imageNamed:@"6"];
        [self.backView addSubview:imageView];
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(WIDTH/19, 12*HEIGHT/667, WIDTH/6-WIDTH/18, 26*HEIGHT/667)];
        
        //color1
        label.textColor = [UIColor colorWithRed:127 / 255.f green:194 / 255.f blue:253/ 255.f alpha:1.000];
        label.text = @"返回";
        [self.backView addSubview:label];
        self.seg = [[UISegmentedControl alloc] initWithItems:@[@"全部内容", @"只看楼主"]];
        self.seg.frame = CGRectMake(70*WIDTH/375 + 8, 20*HEIGHT/667, 230*WIDTH/375, 30*HEIGHT/667);
        self.seg.tintColor = [UIColor colorWithRed:127 / 255.f green:194 / 255.f blue:253/ 255.f alpha:1.000];
        [self addSubview:self.seg];
        self.seg.selectedSegmentIndex = 0;
        
        
        self.moreLabel = [[UILabel alloc] initWithFrame:CGRectMake(305*WIDTH/375 + 5, 24*HEIGHT/667, 60*WIDTH/375, 26*HEIGHT/667)];
      self.moreLabel.text = @"更多";
        self.moreLabel.textColor = [UIColor colorWithRed:127 / 255.f green:194 / 255.f blue:253/ 255.f alpha:1.000];
        self.moreLabel.textAlignment = 1;
        self.moreLabel.userInteractionEnabled = YES;
        [self addSubview:self.moreLabel];
    }
    return self;
}

- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [[touches allObjects] lastObject];
    if (self.backView == touch.view) {
        self.block1(touch);
    } else if(self.moreLabel == touch.view) {
        self.block2(touch);
    }
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
